home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 6639 / 6639.xpi / chrome / easydragtogo.jar / content / easydragtogoBinding.xml < prev    next >
Extensible Markup Language  |  2009-06-14  |  8KB  |  184 lines

  1. <?xml version="1.0"?>
  2. <!DOCTYPE dialog [
  3.   <!ENTITY % settingsDTD SYSTEM "chrome://easydragtogo/locale/easydragtogoConfig.dtd"> %settingsDTD;
  4. ]>
  5.  
  6. <!--  Code from Drag De Go, modifided by Sunwan.  -->
  7.  
  8. <bindings id="easydragtogoBindings"
  9.     xmlns="http://www.mozilla.org/xbl"
  10.     xmlns:xbl="http://www.mozilla.org/xbl"
  11.     xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  12.  
  13.   <binding id="gMenuList" extends="chrome://easydragtogo/content/easydragtogoBinding.xml#gMenuFunc">
  14.     <content>
  15.       <xul:menulist class="easydragtogo-Menu" minwidth="&gesture.menuSearch.width;">
  16.         <xul:menupopup maxheight="250px">
  17.           <xul:menuitem value="link-fg" label="&settings.link-fg;"/>
  18.           <xul:menuitem value="link-bg" label="&settings.link-bg;"/>
  19.           <xul:menuitem value="link-cur" label="&settings.link-cur;"/>
  20.           <xul:menuitem value="save-link" label="&settings.save-link;"/>
  21.           <xul:menuitem value="search-fg" label="&settings.search-fg;"/>
  22.           <xul:menuitem value="search-bg" label="&settings.search-bg;"/>
  23.           <xul:menuitem value="search-cur" label="&settings.search-cur;"/>
  24.           <xul:separator class="groove"/>
  25.           <xul:menuitem value="img-fg" label="&settings.img-fg;"/>
  26.           <xul:menuitem value="img-bg" label="&settings.img-bg;"/>
  27.           <xul:menuitem value="img-cur" label="&settings.img-cur;"/>
  28.           <xul:menuitem value="save-img" label="&settings.save-img;"/>
  29.           <xul:menuitem value="save-df-img" label="&settings.save-df-img;"/>
  30.           <xul:separator class="groove"/>
  31.           <xul:menuitem value="do-nothing" label="&settings.do-nothing;"/>
  32.         </xul:menupopup>
  33.       </xul:menulist>
  34.       <xul:hbox class="easydragtogo-Menu">
  35.         <xul:label value="&settings.search-engine;"/>
  36.         <xul:menulist class="easydragtogo-Menu" minwidth="&gesture.menuEngine.width;">
  37.           <xul:menupopup maxheight="250px" onpopupshowing="easyDragSettings.createEnginesList(this);">
  38.             <xul:menuitem value="c" label="&settings.engine-current;"/>
  39.             <xul:menuitem value="d" label="&settings.engine-default;"/>
  40.             <xul:separator class="groove"/>
  41.           </xul:menupopup>
  42.         </xul:menulist>
  43.       </xul:hbox>
  44.     </content>
  45.   </binding>
  46.  
  47.   <binding id="gMenuFunc">
  48.     <implementation>
  49.       <constructor><![CDATA[
  50.           var pref = Components.classes['@mozilla.org/preferences-service;1'].
  51.                 getService(Components.interfaces.nsIPrefService).getBranch("extensions.easydragtogo.custom.");
  52.           var prefNames = pref.getChildList( "", {} );
  53.           if (prefNames[0] || prefNames.length > 1) {
  54.             var popup = document.getAnonymousNodes(this)[0].childNodes[0];
  55.             var m = popup.appendChild(document.createElement("menuseparator"));
  56.             m.setAttribute("class", "groove");
  57.           }
  58.           for each (var aPref in prefNames) {
  59.             if (aPref) {
  60.               m = popup.appendChild(popup.childNodes[0].cloneNode(true));
  61.               m.setAttribute("value", "custom#" + aPref);
  62.               m.setAttribute("label", "Custom: " + aPref);
  63.             }
  64.           }
  65.  
  66.           var mItems = document.getAnonymousNodes(this)[0].childNodes[0].childNodes;
  67.           var sItems = [];
  68.           for each (var mItem in mItems) {
  69.             var mValue = mItem.value;
  70.             if(mValue) {
  71.               if(mValue.indexOf("custom#")>=0) mItem.hidden = false;
  72.               else if(mValue.indexOf("link")>=0) mItem.hidden = this._Type == "text";
  73.               else if(mValue.indexOf("search-")>=0) mItem.hidden = !(this._Type == "text");
  74.               else if(mValue.indexOf("img")>=0) mItem.hidden = !(this._Type == "image");
  75.               sItems.push(!mItem.hidden);
  76.             }
  77.             else {
  78.               for each (var sItem in sItems) {
  79.                 if(sItem) {
  80.                   mItem.hidden = false;
  81.                   break;
  82.                 }
  83.                 mItem.hidden = true;
  84.               }
  85.               sItems = [];
  86.             }
  87.           }
  88.       ]]>
  89.       </constructor>
  90.  
  91.       <property name="_Type"
  92.           onget="return this.getAttribute('_Type');"/>
  93.       <property name="_disabled">
  94.         <getter><![CDATA[
  95.           return document.getAnonymousNodes(this)[0].disabled;
  96.         ]]></getter>
  97.         <setter><![CDATA[
  98.           document.getAnonymousNodes(this)[0].disabled = val;
  99.           document.getAnonymousNodes(this)[1].childNodes[1].disabled = val;
  100.         ]]></setter>
  101.       </property>
  102.       <property name="_engine">
  103.         <getter><![CDATA[
  104.           return document.getAnonymousNodes(this)[1].childNodes[1].value;
  105.         ]]></getter>
  106.         <setter><![CDATA[
  107.           var menu = document.getAnonymousNodes(this)[1].childNodes[1];
  108.           menu.value = val;
  109.           try {
  110.             if ((val == "c" || val == "d") && menu.getAttribute("label").indexOf("[") == -1) {
  111.               var ss = Components.classes["@mozilla.org/browser/search-service;1"].
  112.                         getService(Components.interfaces.nsIBrowserSearchService);
  113.               if (val == "c" && ss.currentEngine)
  114.                 menu.setAttribute("label", menu.getAttribute("label") + "[" + ss.currentEngine.name + "]");
  115.               else if (val == "d" && ss.defaultEngine)
  116.                 menu.setAttribute("label", menu.getAttribute("label") + "[" + ss.defaultEngine.name + "]");
  117.             }
  118.             else if (val != "c" && val != "d")
  119.               menu.setAttribute("label", val);
  120.           } catch(e) {}
  121.         ]]></setter>
  122.       </property>
  123.       <property name="_engineHidden"
  124.           onget="return document.getAnonymousNodes(this)[1].hidden;"
  125.           onset="document.getAnonymousNodes(this)[1].hidden = val;"/>
  126.       <property name="_selectedItem">
  127.         <getter><![CDATA[
  128.           return document.getAnonymousNodes(this)[0].selectedItem.value;
  129.         ]]></getter>
  130.         <setter><![CDATA[
  131.           if (val.indexOf("search-") == 0)
  132.             this._engineHidden = false;
  133.           else
  134.             this._engineHidden = true;
  135.           document.getAnonymousNodes(this)[0].value = val;
  136.           if (this._Type == "image")
  137.             easyDragSettings.updateImgFloderStatus();
  138.         ]]></setter>
  139.       </property>
  140.     </implementation>
  141.     <handlers>
  142.       <handler event="command"
  143.                action="this._selectedItem = document.getAnonymousNodes(this)[0].selectedItem.value;"/>
  144.     </handlers>
  145.   </binding>
  146.   
  147.   <binding id="easydragtogo-Direction">
  148.     <content>
  149.       <xul:radiogroup class="easydragtogo-Menu">
  150.         <xul:hbox class="easydragtogo-Menu">
  151.           <xul:radio class="direc-four"/>
  152.           <xul:radio class="direc-ud"/>
  153.           <xul:radio class="direc-rl"/>
  154.           <xul:radio class="direc-any"/>
  155.           <xul:radio class="direc-none"/>
  156.         </xul:hbox>
  157.       </xul:radiogroup>
  158.     </content>
  159.     <implementation>
  160.       <property name="_mId"
  161.           onget="return this.getAttribute('_mId');"/>
  162.       <property name="_selectedIndex"
  163.           onget="return document.getAnonymousNodes(this)[0].selectedIndex;"
  164.           onset="document.getAnonymousNodes(this)[0].selectedIndex = val;this.getDirection();"/>
  165.       <method name="getDirection">
  166.         <body><![CDATA[
  167.           var mode = this._selectedIndex;
  168.           document.getElementById(this._mId + '-edg-any')._disabled= mode!=3;
  169.           document.getElementById(this._mId + '-edg-up')._disabled= mode==2 || mode==3 || mode==4;
  170.           document.getElementById(this._mId + '-edg-down')._disabled= mode==2 || mode==3 || mode==4;
  171.           document.getElementById(this._mId + '-edg-right')._disabled= mode==1 || mode==3 || mode==4;
  172.           document.getElementById(this._mId + '-edg-left')._disabled= mode==1 || mode==3 || mode==4;
  173.           if (this._mId == "img")
  174.             easyDragSettings.updateImgFloderStatus();
  175.         ]]></body>
  176.       </method>
  177.     </implementation>
  178.     <handlers>
  179.       <handler event="command" action="this.getDirection();"/>
  180.     </handlers>
  181.   </binding>
  182.  
  183. </bindings>
  184.